<?php
// ensure this file is being included by a parent file
defined( '_VALID_MOS' ) or defined( '_JEXEC' ) or die( 'Restricted access' );
	  global $mosConfig_absolute_path;//, $mainframe;//test


$nik_basePath = dirname(__FILE__);

require_once( $nik_basePath.'/niktranslate.class.php' );
?>
<style type="text/css" media="all">
<?php require_once( $nik_basePath.'/niktranslate.css' ); ?>
</style>


	<div align="left">
<?php
		  $dirs = _getRecursiveFolderList($mosConfig_absolute_path);
#	  echo '<hr />'.$this->workPath.'<hr />'.$mosConfig_absolute_path.'<hr />';
#				echo '<pre>';
				//var_dump( $dirs );
#				echo '</pre>';
#	  echo '<hr />yup<hr />';
	  $workPath = $mosConfig_absolute_path.'/components/com_bindex/language';//'/com_comprofiler/plugin/language';
#	  echo $workPath;
	  $files = glob($workPath.'/*.php');
#	  echo '<hr />'.$this->workPath.'<hr />'.$mosConfig_absolute_path.'<hr />';
//				echo '<pre>';
//				var_dump( $files );
//				echo '</pre>';
#	  echo '<hr />yup2<hr />';
//echo  $files[0].'<br />';
//echo  $files[1].'<br />';

$translator = new niktranslate;

$translator->translate($files[0],$files[1]);


?>

<h1>TRANS</h1>
Path ref:
<?php echo $translator->path_ref; ?> <br />
Path trans:
<?php echo $translator->path_trans; ?> <br />


<table  width="100%">
	<tr>
		<td>&nbsp;</td>
		<td>
			<?php echo $translator->filename_ref; ?>
		</td>
		<td>
			<?php echo $translator->filename_trans; ?>
		</td>
	</tr>	
	<tr class="trans_header">
		<td>&nbsp;</td>
		<td>
						<table width="100%">
							<?php
							foreach( $translator->header_ref as $result )
							{
								 ?>
									<tr class="trans_header">
										<td>
											<input size ="40" class="trans_header_box" value="<?php echo $result; ?>" />
										</td>
									</tr>
									<?php		
							} //foreach
							?>
						</table>
					</td>
					<td>
						<table width="100%">
							<?php
							foreach( $translator->header_trans as $result )
							{
								 ?>
									<tr class="trans_header">
										<td>
											<input size ="40" class="trans_header_box" value="<?php echo $result; ?>" />
										</td>
									</tr>
									<?php		
							} //foreach
							?>
						</table>
					</td>
	</tr>

<?php
foreach( $translator->items as $result )
{
	if( $result->comment)
	{ ?>
		<tr class="trans_comment">
			<!--<td>&nbsp;</td>-->
			<td colspan="3" class="trans_comment" align="center"><input size ="60"  class="trans_comment_box"value="<?php echo $result->mean; ?>" /></td>
			<!-- <td>&nbsp;<?php //echo $result->trans; ?></td>-->
		</tr>
		<?php		
	} else
	{
		echo '<tr class="trans_tr"><td><span class="trans_definition">'.$result->def.'</span></td>';
		if(strlen( $result->mean) < 40 )
		{
			echo '<td class="borders"><input size ="40" class="trans_definition_box" value="'.htmlentities($result->mean).'" /></td>';
			echo '<td><input size ="40" class="trans_definition_box" value="'.htmlentities($result->trans).'" /></td>';
		} else
		{
			echo '<td><textarea name="user_eingabe" class="trans_definition_box" cols="30" rows="3">'.htmlentities($result->mean).'</textarea></td>';
			echo '<td><textarea name="user_eingabe" class="trans_definition_box" cols="30" rows="3">'.htmlentities($result->trans).'</textarea></td>';
		}
		echo '</tr>';
	}
}

echo '</table>';


//					echo '<pre>';
//					var_dump( $translator->items );
//					echo '</pre>';

//echo '<h1>end for each</h1>';


//				echo '<pre>';
//				var_dump( $inhalt );
//				echo '</pre>';

//$Translator = new niktranslate( 'components/com_comprofiler/plugin/language/default-language');
echo '</div>';

  
  function _getRecursiveFolderList($curDir,$currentA=false)
  {                   
        $dirs = glob($curDir . '/*', GLOB_ONLYDIR);    
       
        $cur = 0;
        foreach($dirs as $dir)
          {
            $currentA[$cur]['path'] = $dir;
            $currentA[$cur] = _getRecursiveFolderList($dir,$currentA[$cur]);
               
            ++$cur;
          }

        return $currentA;
   }
?>